package com.moyoutian.daogenerate.service.impl;

import com.moyoutian.daogenerate.entity.ColumnEntity;
import com.moyoutian.daogenerate.entity.ColumnId;
import com.moyoutian.daogenerate.repository.ColumnRepository;
import com.moyoutian.daogenerate.service.ColumnService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Transactional(rollbackFor = Exception.class)
@Service
@Slf4j
@AllArgsConstructor
public class ColumnServiceImpl implements ColumnService {

    private final ColumnRepository repository;

    @Override
    public List<ColumnEntity> findAll(ColumnEntity columnEntity) {
        //要匹配的实例对象
        // 定义匹配规则 匹配"vendorId"这个属性 exact 精准匹配
//        ExampleMatcher exampleMatcher = ExampleMatcher.matching().
//                withMatcher("", ExampleMatcher.GenericPropertyMatchers.exact());
//        Sort.Direction sort = Sort.Direction.ASC;
        Example<ColumnEntity> example = Example.of(columnEntity);
        return repository.findAll(example);
    }

    @Override
    public ColumnEntity getOne(ColumnId columnId) {
        return repository.getOne(columnId);
    }


}
